﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;

namespace BUS
{
    public class tbSanPhamBus
    {
        public static void Insert_SanPham(tbSanPham sanpham)
        {
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            sanphamDAL.Insert(sanpham);
        }
        public static void Update_SanPham(tbSanPham sanpham)
        {
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            sanphamDAL.Update(sanpham);
        }
        public static void Delete_SanPham(int Id)
        {
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            sanphamDAL.Delete(Id);
        }
        public static tbSanPham.tbSanPhamCollection Get(string Where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {

            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            return (sanphamDAL.Get(Where, pageindex, pagesize, orderby, orderdirection, out total));
        }
        public static tbSanPham.tbSanPhamCollection GetAll()
        {
            int total = 0;
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            return sanphamDAL.Get("Where 1=1", 0, 0, tbSanPham.tbSanPhamColumns.IDSanPham.ToString(), "ASC", out total);
        }
        public static tbSanPham GetByID(int iD)
        {
            int total = 0;
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            tbSanPham.tbSanPhamCollection sanphamcollection = sanphamDAL.Get("where " + tbSanPham.tbSanPhamColumns.IDSanPham.ToString() + "=" + iD.ToString(), 0, 0, tbSanPham.tbSanPhamColumns.IDSanPham.ToString(), "ASC", out total);
            if (sanphamcollection.Count > 0)
                return sanphamcollection[0];
            return null;
        }

    } 
}
